class LoginController < ApplicationController
  def index
    login
    render :action => 'login'
  end
  def login
    if request.get?
      session[:user_id]=nil
      @user=User.new
    else
      @user=User.new(params[:user])
      logged_in_user=@user.try_to_login
    if logged_in_user
      session[:user_id]=logged_in_user.id
      redirect_to(:controller => "manage",
                  :action => "show")
    else
      flash[:notice]= 'Invalid user/password conbination'
    end
    end
  end
  
  def logout
    session[:user_id]=nil
    flash[:notice]= "已退出，谢谢您的工作"
    redirect_to( :controller =>"login",
                 :action=> "login")
  end  
end
